﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="frmGenerarPedido.aspx.cs" Inherits="Farmacia.net.Ventas.Pedido.frmGenerarPedido" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .style3
        {
            width: 100%;
        }
        .style4
        {
            width: 91px;
            text-align: right;
        }
        .style5
        {
            text-align: right;
        }
        .style6
        {
            text-align: center;
        }
        .style7
        {
            width: 69px;
        }
        .style8
        {
            width: 34px;
        }
        .style9
        {
            width: 62px;
        }
        .style10
        {
            width: 91px;
        }
        .style11
        {
            width: 137px;
            text-align: right;
        }
        .style12
        {
            width: 209px;
        }
        .style13
        {
            width: 320px;
        }
        .style14
        {
            width: 85px;
        }
        .style15
        {
            width: 84px;
        }
        .style16
        {
            width: 65px;
        }
        .style17
        {
            width: 271px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Pedido</h2>

    <table cellpadding="2" class="style3">
        <tr>
            <td class="style5">
                &nbsp;</td>
            <td class="style5">
                &nbsp;</td>
            <td class="style5"> Nro. Pedido : </td>
            <td><asp:TextBox ID="txtPedido" runat="server"></asp:TextBox></td>
            <td class="style5">Fecha :</td>
            <td><asp:TextBox ID="txtFecha" runat="server" Enabled="False"></asp:TextBox></td>
        </tr>
    </table>

    <fieldset>
    <legend>Cliente
   </legend>
        <table class="style3">
            <tr>
                <td class="style4">Ruc/Dni :</td>
                <td><asp:TextBox ID="txtRuc" runat="server"></asp:TextBox>
                    <asp:Button ID="btnBuscarCliente" runat="server"  Text="..." />

                    <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" 
                        CancelControlID="btncancelclie" OkControlID="btnacptclie" 
                        PopupControlID="pnlClientes" BackgroundCssClass="FondoAplicacion" 
                        TargetControlID="btnBuscarCliente">
                    </ajaxToolkit:ModalPopupExtender>

                </td>
            </tr>
            <tr>
                <td class="style4">Razón Social:</td><td><asp:TextBox ID="txtRazonSocial" 
                    runat="server" Width="325px"></asp:TextBox></td>
            </tr>
            <tr>
                <td class="style4">Dirección:</td><td><asp:TextBox ID="txtDirec" runat="server" 
                    Width="325px"></asp:TextBox>             </td>
            </tr>
        </table>
    </fieldset>

    <fieldset><legend>Producto</legend>
    
        <table class="style3">
            <tr>
                <td class="style7">
                    Cantidad</td>
                <td class="style8">
                    &nbsp;</td>
                <td class="style9">
                    Codigo</td>
                <td class="style10">
                    Descripción</td>
                <td class="style14">
                    Unidad</td>
                <td class="style15">
                    Precio &nbsp;</td>
                <td class="style16">
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style7">
                    <asp:TextBox ID="txtCant" runat="server" Width="60px"></asp:TextBox>
                </td>
                <td class="style8">
                    <asp:Button ID="btnBuscarProd" runat="server" Text="..." Width="30px" />
                </td>
                <td class="style9">
                    <asp:TextBox ID="txtCodigo" runat="server" Width="60px"></asp:TextBox>
                </td>
                <td class="style10">
                    <asp:TextBox ID="txtDescripcion" runat="server" Width="278px"></asp:TextBox>
                </td>
                <td class="style14">
                    <asp:TextBox ID="txtUnd" runat="server" Width="80px"></asp:TextBox>
                </td>
                <td class="style15">
                    <asp:TextBox ID="txtPrecio" runat="server" Width="80px"></asp:TextBox>
                </td>
                <td class="style16">
                    <asp:Button ID="btnAgregar" runat="server" Text="Agregar" Width="60px" 
                        onclick="btnAgregar_Click" />
                </td>
                <td>
                    &nbsp;</td>
            </tr>
            </table>
    
                <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender2" runat="server" 
            CancelControlID="btnCancelarprod" OkControlID="btnaceptarprod" 
            TargetControlID="btnBuscarProd" BackgroundCssClass="FondoAplicacion" 
            PopupControlID="pnlProd" ondatabinding="gvClientes_SelectedIndexChanged">
                </ajaxToolkit:ModalPopupExtender>

    </fieldset>

    <fieldset><legend>Detalle Pedido</legend>
        <asp:UpdatePanel ID="Updatedtlle" runat="server">
        <ContentTemplate>

        <asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" 
            GridLines="None" AutoGenerateColumns="False" Width="100%">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:BoundField DataField="Cantidad" HeaderText="Cantidad" />
                <asp:BoundField DataField="IdProducto" HeaderText="Codigo" />
                <asp:BoundField DataField="Descripcion" HeaderText="Descripción" />
                <asp:BoundField DataField="Unidad" HeaderText="Unidad" />
                <asp:BoundField DataField="Precio" HeaderText="Precio" />
                <asp:BoundField DataField="Monto" HeaderText="Monto" />
                <asp:ButtonField Text="Quitar" />
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>

            <br />
            <asp:Label ID="lblTotal" runat="server" Text="Total" Font-Size ="19pt"></asp:Label>

        </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnAgregar" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
        
    
        <br />
        <asp:Button ID="btnRegistrar" runat="server" Text="Registrar" 
            onclick="btnRegistrar_Click" />
        
    
    </fieldset>




    <!-- Mis Paneles-->
    <asp:Panel ID="pnlClientes" runat="server">
    <fieldset>
    <legend>Buscar Cliente</legend>
    
        
        <b>Criterio:</b><asp:TextBox ID="txtCriterio" runat="server"></asp:TextBox>
        <asp:Button ID="btnBuscar" runat="server" Text="Buscar" 
            onclick="btnBuscar_Click" />
        <br/>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <asp:GridView ID="gvClientes" runat="server" AutoGenerateColumns="False" 
            DataSourceID="odsCliente" CellPadding="4" ForeColor="#333333" 
            GridLines="None" Width="100%" AllowPaging="True" DataKeyNames="RucDni" 
                onselectedindexchanged="gvClientes_SelectedIndexChanged">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" />
                <asp:BoundField DataField="IdCliente" HeaderText="IdCliente" 
                    SortExpression="IdCliente" />
                <asp:BoundField DataField="RucDni" HeaderText="RucDni" 
                    SortExpression="RucDni" />
                <asp:BoundField DataField="RazonSocial" HeaderText="RazonSocial" 
                    SortExpression="RazonSocial" />
                <asp:BoundField DataField="Direccion" HeaderText="Direccion" 
                    SortExpression="Direccion" />
                <asp:BoundField DataField="Telefono" HeaderText="Telefono" 
                    SortExpression="Telefono" />
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
        <asp:ObjectDataSource ID="odsCliente" runat="server" 
            onobjectcreating="odsCliente_ObjectCreating" 
            SelectMethod="GetFromClienteByRazonSocialAndRucDni" 
            TypeName="Farmacia.BussinessLogic.ClienteBL">
            <SelectParameters>
                <asp:ControlParameter ControlID="txtCriterio" DefaultValue="%" Name="criterio" 
                    PropertyName="Text" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>
        </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnBuscar" EventName="Click" />
                <asp:AsyncPostBackTrigger ControlID="ddlGrupFarm" 
                    EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="ddlLab" EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="ddlPrincAct" 
                    EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="ddlProveedor" 
                    EventName="SelectedIndexChanged" />
            </Triggers>
        </asp:UpdatePanel>
        <asp:Button ID="btnacptclie" runat="server" Text="Aceptar" style="text-align: right" />
        <asp:Button ID="btncancelclie" runat="server" Text="Cancelar" style="text-align: right" />
        </fieldset>
    </asp:Panel>

    <!--Producto-->
    <asp:Panel ID="pnlProd" runat="server">
    <fieldset>          
            <fieldset id="criterio prod">
            <legend>Buscar:</legend>
           <div class="style6">
            <b>Criterio :<asp:TextBox ID="txtProd" runat="server" Height="20px" 
                Width="259px"></asp:TextBox>
            <asp:Button ID="btnBuscarProducto" runat="server" Text="Buscar" 
                   onclick="btnBuscarProducto_Click" />
            </b>
            <br />
        </div>
        </fieldset >
        <!--Filtros-->
        <fieldset id="fieldsetfiltros">
        <legend>Filtrar Por:</legend>
        <table class="style3" width="100%">
            <tr>
                <td class="style11">
                    Laboratorio:</td>
                <td class="style12">
                    <asp:DropDownList ID="ddlLab" runat="server" AutoPostBack="True" 
                        DataSourceID="odsLab" DataTextField="Nombre" 
                        DataValueField="Nombre" AppendDataBoundItems="True" Width="200px">
                        <asp:ListItem Selected="True" Value="%">Seleccionar...</asp:ListItem>
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="odsLab" runat="server" 
                        onobjectcreating="odsLab_ObjectCreating" SelectMethod="GetAllFromLaboratorio" 
                        TypeName="Farmacia.BussinessLogic.Almacen.Laborat.LaboratorioBL">
                    </asp:ObjectDataSource>
                </td>
                <td class="style5">
                    Principio Activo:</td>
                <td class="style13">
                    <asp:DropDownList ID="ddlPrincAct" runat="server" AutoPostBack="True" 
                        DataSourceID="odsPrinc" DataTextField="Nombre" 
                        DataValueField="Nombre" AppendDataBoundItems="True" Width="200px">
                        <asp:ListItem Selected="True" Value="%">Seleccionar...</asp:ListItem>
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="odsPrinc" runat="server" 
                        onobjectcreating="odsPrinc_ObjectCreating" SelectMethod="GetAllFromPrincActivo" 
                        TypeName="Farmacia.BussinessLogic.Almacen.PrincActivo.PrincipioActivoBL">
                    </asp:ObjectDataSource>
                </td>
            </tr>
            <tr>
                <td class="style11">
                    Grupo Farmacológico</td>
                <td class="style12">
                    <asp:DropDownList ID="ddlGrupFarm" runat="server" AutoPostBack="True" 
                        DataSourceID="odsGrupFarm" DataTextField="Nombre" 
                        DataValueField="Nombre" AppendDataBoundItems="True" Height="16px" 
                        Width="200px">
                        <asp:ListItem Selected="True" Value="%">Seleccionar...</asp:ListItem>
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="odsGrupFarm" runat="server" 
                        onobjectcreating="odsGrupFarm_ObjectCreating" 
                        SelectMethod="GetAllGrupoFarmacologico" 
                        TypeName="Farmacia.BussinessLogic.Almacen.GrupoFarma.GrupoFarmaBL">
                    </asp:ObjectDataSource>
                </td>
                <td class="style5">
                    Proveedor :</td>
                <td class="style13">
                    <asp:DropDownList ID="ddlProveedor" runat="server" AutoPostBack="True" 
                        DataSourceID="odsProveedor" DataTextField="RazonSocial" 
                        DataValueField="RazonSocial" AppendDataBoundItems="True" Width="200px">
                        <asp:ListItem Selected="True" Value="%">Seleccionar...</asp:ListItem>
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="odsProveedor" runat="server" 
                        onobjectcreating="odsProveedor_ObjectCreating" 
                        SelectMethod="GetAllFromProveedor" 
                        TypeName="Farmacia.BussinessLogic.ProveedorBL"></asp:ObjectDataSource>
                </td>
            </tr>
        </table>
        </fieldset>
        
         <br />

                <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                <ContentTemplate>
                
                <table class="style3">
                <tr>
                    <td>
                    <!-- Producto -->
                <asp:GridView ID="GridView2" runat="server" AllowPaging="True" 
                    AutoGenerateColumns="False" DataSourceID="odsProducto" CellPadding="4" 
                    ForeColor="#333333" GridLines="None" Width="100%" 
                        onselectedindexchanged="GridView2_SelectedIndexChanged" 
                        DataKeyNames="IdProducto">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="IdProducto" HeaderText="Id" 
                            SortExpression="IdProducto" />
                        <asp:BoundField DataField="Descripcion" HeaderText="Descripcion" 
                            SortExpression="Descripcion" />
                        <asp:BoundField DataField="Proveedor" HeaderText="Prov" 
                            SortExpression="Proveedor" />
                        <asp:BoundField DataField="Laboratorio" HeaderText="Laborat" 
                            SortExpression="Laboratorio" />
                        <asp:BoundField DataField="GrupoFarmacologico" HeaderText="Grupo" 
                            SortExpression="GrupoFarmacologico" />
                        <asp:BoundField DataField="PrincActivo" HeaderText="Principio" 
                            SortExpression="PrincActivo" />
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <asp:ObjectDataSource ID="odsProducto" runat="server" 
                    SelectMethod="GetFromProdbyCriterioAndLaboratorioANDPrincipioActivoANDGrupoFarmacologicoANDPROVEEDOR" 
                    TypeName="Farmacia.BussinessLogic.ProductoBL" 
                    onobjectcreating="odsProducto_ObjectCreating">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="txtProd" DefaultValue="%" 
                            Name="Criterio" PropertyName="Text" Type="String" />
                        <asp:ControlParameter ControlID="ddlLab" DefaultValue="%" Name="Laboratorio" 
                            PropertyName="SelectedValue" Type="String" />
                        <asp:ControlParameter ControlID="ddlPrincAct" DefaultValue="%" Name="PrincAct" 
                            PropertyName="SelectedValue" Type="String" />
                        <asp:ControlParameter ControlID="ddlGrupFarm" DefaultValue="%" Name="GrupFarm" 
                            PropertyName="SelectedValue" Type="String" />
                        <asp:ControlParameter ControlID="ddlProveedor" DefaultValue="" Name="Proveedor" 
                            PropertyName="SelectedValue" Type="String" />
                    </SelectParameters>
                </asp:ObjectDataSource>
                        </td>
                </tr>
                <tr>
                    <td>
                    <!-- Prod por Almacen -->
                    <asp:GridView ID="GridView3" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="Id" 
                        DataSourceID="odsstockporprod" ForeColor="#333333" GridLines="None" 
                        Width="42%">
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <Columns>
                            <asp:CommandField ShowSelectButton="True" />
                            <asp:BoundField DataField="Ubicacion" HeaderText="Ubicacion" 
                                SortExpression="Ubicacion" />
                            <asp:BoundField DataField="Precio" HeaderText="Precio" 
                                SortExpression="Precio" />
                            <asp:CheckBoxField DataField="Act" HeaderText="Act" SortExpression="Act" />
                        </Columns>
                        <EditRowStyle BackColor="#999999" />
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#E9E7E2" />
                        <SortedAscendingHeaderStyle BackColor="#506C8C" />
                        <SortedDescendingCellStyle BackColor="#FFFDF8" />
                        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                    </asp:GridView>
                    <asp:ObjectDataSource ID="odsstockporprod" runat="server" 
                        onobjectcreating="odsstockporprod_ObjectCreating" 
                        SelectMethod="GetFromProdAlmacenadoStockTotalbyIdProducto" 
                        TypeName="Farmacia.BussinessLogic.ProductoBL">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="GridView2" Name="IdProducto" 
                                PropertyName="SelectedValue" Type="Int32" />
                        </SelectParameters>
                    </asp:ObjectDataSource>
                </tr>
                    <tr>
                        <td>
<!-- Prod Stock por almacen-->
                <asp:GridView ID="GridView4" runat="server" AllowPaging="True" 
                AutoGenerateColumns="False" CellPadding="4" DataSourceID="odsStockporUbicación" 
                ForeColor="#333333" GridLines="None" Width="100%" DataKeyNames="Codigo" 
                        onselectedindexchanged="GridView4_SelectedIndexChanged">
                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                <Columns>
                    <asp:CommandField ShowSelectButton="True" />
                    <asp:BoundField DataField="Id" HeaderText="Id" SortExpression="Id" />
                    <asp:BoundField DataField="Codigo" HeaderText="Codigo" 
                        SortExpression="Codigo" />
                    <asp:BoundField DataField="Nombre" HeaderText="Nombre" 
                        SortExpression="Nombre" />
                    <asp:BoundField DataField="NroLote" HeaderText="NroLote" 
                        SortExpression="NroLote" />
                    <asp:BoundField DataField="Vence" HeaderText="Vence" SortExpression="Vence" />
                    <asp:BoundField DataField="Und" HeaderText="Und" SortExpression="Und" />
                    <asp:BoundField DataField="StockU" HeaderText="SubxUnd" 
                        SortExpression="StockU" />
                    <asp:BoundField DataField="SubUnd" HeaderText="SubUnd" 
                        SortExpression="SubUnd" />
                    <asp:BoundField DataField="StockSub" HeaderText="StockSub" 
                        SortExpression="StockSub" />
                    <asp:CheckBoxField DataField="Activo" HeaderText="Activo" 
                        SortExpression="Activo" />
                </Columns>
                <EditRowStyle BackColor="#999999" />
                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                <SortedAscendingCellStyle BackColor="#E9E7E2" />
                <SortedAscendingHeaderStyle BackColor="#506C8C" />
                <SortedDescendingCellStyle BackColor="#FFFDF8" />
                <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
            </asp:GridView>
                <asp:ObjectDataSource ID="odsStockporUbicación" runat="server" 
                onobjectcreating="odsStockporUbicación_ObjectCreating" 
                SelectMethod="GetProdStockbyAlmacen" 
                TypeName="Farmacia.BussinessLogic.ProductoBL">
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridView3" Name="IdAlmcen" 
                        PropertyName="SelectedValue" Type="Int32" />
                    <asp:ControlParameter ControlID="GridView2" Name="IdProducto" 
                        PropertyName="SelectedValue" Type="Int32" />
                </SelectParameters>
            </asp:ObjectDataSource></td></td>
                    </tr>
            </table>
                
 

                </ContentTemplate>

                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="btnBuscarProd" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="GridView2" 
                        EventName="SelectedIndexChanged" />
                    <asp:AsyncPostBackTrigger ControlID="GridView3" 
                        EventName="SelectedIndexChanged" />
                    <asp:AsyncPostBackTrigger ControlID="GridView1" 
                        EventName="SelectedIndexChanged" />
                </Triggers>

        </asp:UpdatePanel>
                  

            
            
            <br />
                  <asp:Button ID="btnaceptarprod" runat="server" Text="Aceptar" />
                <asp:Button ID="btnCancelarprod" runat="server" Text="Cancelar" />
                <br />
                <br />
                    <br />
                    <br />
                



                   
    </fieldset>
    </asp:Panel>

</asp:Content>
